package site.assad.conf1;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import site.assad.conf.LogonService;
import site.assad.conf1.DaoConfig;

/**
 * Author: Al-assad 余林颖
 * E-mail: yulinying_1994@outlook.com
 * Date: 2017/11/30 16:50
 * Description: 拆分方式配置：对 LogonService 标注为Bean的JavaConfig类
 */

@Configuration
@Import(DaoConfig.class)   //导入DaoConfig的配置信息,将其进行组合
public class ServiceConfig {

    //自动注入DaoConfig
    @Autowired
    private DaoConfig daoConfig;

    @Bean
    public LogonService logonService(){
        LogonService logonService = new LogonService();
        logonService.setLogDao(daoConfig.logDao());
        logonService.setUserDao(daoConfig.userDao());
        return logonService;
    }

}
